import React from 'react'

class Father extends React.Component{
    state = {
        count: 0
    }
    addDate = () => {
        // 更新状态
        this.setState({
            count: this.state.count+1
        })
    }
    render(){
        return (
            <div>
                <Child1 count = {this.state.count}></Child1>
                <Child2 add={this.addDate}></Child2>
            </div>
        )
    }
}

class Child1 extends React.Component{
    render(){
        return (
            <div>计数器{this.props.count}</div>
        )
    }
}
class Child2 extends React.Component{
    render(){
        return (
            <button onClick = {this.props.add}>+1</button>
        )
    }
}
export {
    Father
}